package org.learm.base.array;

/**
 * 数组类:
 * 	
 * @author 5king
 *
 */
public class ArrayTest {
	
	//一维数组
	//数组类型[] 数组名 = new 数组类型[数组中元素个数] 下标从零开始  length获取数组长度
	private static int[] array = new int[2]; //默认值{0,0} 
	
	//定义数组并初始化
	private static int[] array2 = new int[] {1,2,3};
	
	//简单定义
	@SuppressWarnings("unused")
	private static int[] array3 = {0,1,2,3};
	
	//多维数组
	//数组类型[][][]... 数组名 = new 数组类型[m][n][l]... l表示有多少个元素 n表示多少个l m表示有多少个n 依次类推
	@SuppressWarnings("unused")
	private static String[][][] str = new String[2][2][6];
	
	//赋值
	@SuppressWarnings("unused")
	private static String[][] str2 = new String[][] {{"1","1"},{"1","1"},{"1","1"}};
	
	//数组遍历
	public static void getArray() {
		//for循环遍历
		for(int i = 0 ; i < array.length ; i++) {
			System.out.println(array[i]);
		}
		
		//foreach 遍历
		for(int i : array2) {
			System.out.println(i);
		}
	}
}
